package com.lmx.repoDomain.tmodel;


import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;


/**
 * 员工排班表
 */
@JsonApiResource(type = "staffschedule")
@Table(name = "tnb_staffschedule")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class StaffSchedule extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private String remark;// 备注

	private String name;//

	private Employee employee;// 护工

	private WorkTimeSetting workTimeSetting;// 班次

	private String year;

	private String month;

	private String week;

	private String day;
	
	private String weekIndex;

	private StaffWorkTimeSetting setting;// 排班

	@Transient
	@JsonApiToOne
	public StaffWorkTimeSetting getSetting() {
		return setting;
	}

	public void setSetting(StaffWorkTimeSetting setting) {
		this.setting = setting;
	}

	@Column(name = "year")
	public String getYear() {
		return year;
	}

	public void setYear(String year) {
		this.year = year;
	}

	@Column(name = "month")
	public String getMonth() {
		return month;
	}

	public void setMonth(String month) {
		this.month = month;
	}

	@Column(name = "week_index")
	public String getWeekIndex() {
		return weekIndex;
	}

	public void setWeekIndex(String weekIndex) {
		this.weekIndex = weekIndex;
	}
	
	@Column(name = "week")
	public String getWeek() {
		return week;
	}

	public void setWeek(String week) {
		this.week = week;
	}

	@Column(name = "day")
	public String getDay() {
		return day;
	}

	public void setDay(String day) {
		this.day = day;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "worktimesetting_id", foreignKey = @ForeignKey(name = "null"))
	public WorkTimeSetting getWorkTimeSetting() {
		return workTimeSetting;
	}

	public void setWorkTimeSetting(WorkTimeSetting workTimeSetting) {
		this.workTimeSetting = workTimeSetting;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "employee_id", foreignKey = @ForeignKey(name = "null"))
	public Employee getEmployee() {
		return employee;
	}

	public void setEmployee(Employee employee) {
		this.employee = employee;
	}

	// @JsonApiToMany
	// @JsonApiIncludeByDefault
	// @Fetch(FetchMode.JOIN)
	// @OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH,
	// mappedBy = "schedule")
	// public Set<StaffScheduleDetail> getDetails() {
	// return details;
	// }
	//
	// public void setDetails(Set<StaffScheduleDetail> details) {
	// this.details = details;
	// }

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @Fetch(FetchMode.JOIN)
	// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	// @JoinColumn(name = "item_id",foreignKey = @ForeignKey(name = "null"))
	// public CustomerServiceItem getItem() {
	// return item;
	// }
	//
	// public void setItem(CustomerServiceItem item) {
	// this.item = item;
	// }

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	public StaffSchedule() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
